package com.example.demo1105.demo3;

import java.util.Arrays;
import java.util.Optional;
/**
 * @Author: FBS
 * @Description: TODO
 * @DateTime: 2022/11/6 20:40
 *@Version:1.0
 */
public class TestThree02 {
    public static void main(String[] args) {
        Integer[] arr ={6,5,2,4,3,8};
        Optional<Integer> reduce = Arrays.stream(arr).reduce((t1, t2) -> t1 += t2);
        System.out.println("reduce = " + reduce);

        Optional<Integer> reduce1 = Arrays.stream(arr).reduce((t1, t2) -> t1 > t2 ? t1 : t2);
        System.out.println("reduce1 = " + reduce1);

        Optional<Integer> reduce2 = Arrays.stream(arr).reduce((t1, t2) -> t1 < t2 ? t1 : t2);
        System.out.println("reduce2 = " + reduce2);
    }
}
